home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / pulldw.zip / XPULLDW.PAS < prev   
Pascal/Delphi Source File  |  1987-12-04  |  5KB  |  151 lines

  1. {
  2. xpulldw.pas -
  3.  
  4. a demonstration program using the pulldown.tpu unit
  5.  
  6. }
  7. program xpulldw;
  8.  
  9. uses dos,crt,pulldown;
  10.  
  11. {$V-}
  12.  
  13. {
  14.   A pulldown menu system consists of a horizontal bar menu of n choices,
  15.   and from 1 to n associated vertical submenus.  The top (or bar) menu may
  16.   have up to 80 characters; each submenu may have up to 255 (see note below
  17.   for submenus with more than 128 characters).
  18.  
  19.   To define a menu, simply declare a typed constant string to represent
  20.   the top menu.  The choices in the menu are demarcated with '|'.
  21.   Then declare typed constants for the submenus in the appropriate order.
  22.   Null submenus (e.g., the 'Edit' choice from the Turbo Pascal main menu)
  23.   are indicated with a string[1] = ' '.  The example below should make
  24.   everything clear.
  25.  
  26.   It may be worthwhile to examine the code in pulldown.pas. I contains
  27.   useful general-purpose procedures for windowing and screen accessing.
  28.  
  29. }
  30.  
  31. const
  32.  
  33. {
  34.   Here the menus are defined.  The maximum lengths of the strings must be
  35.   EXACTLY equal to the actual lengths of the defined constants.  A simple way
  36.   to get it right is to write them as shown below, then place the editor's
  37.   cursor under the ultimate character of the string.  The length will be
  38.   the 'Col' number reported on the editor's status line minus 1.
  39.  
  40.   Note that Turbo Pascal forbids the declaration of string constants longer
  41.   than 128 characters, although the maximum length of the typed constant may
  42.   be declared to be 255.  If you have a long sub-menu (say,200 chars ),
  43.   try the following: declare the constant s as string[200], but initialize
  44.   only the first 128 or less characters; declare another constant which will
  45.   contain the remaining characters; concatenate the second one to the first
  46.   before invoving the menu procedure.
  47.  
  48.          const
  49.            s : str200 = '....100 chars...';
  50.            .
  51.            .
  52.            .
  53.            rest: str100 = '...the remaining 100 chars...';
  54.            .
  55.            .
  56.            .
  57.          begin
  58.            .
  59.            .
  60.            s:=s+rest;
  61.            menu(1,s,.......);
  62.            .
  63.            .
  64.            .
  65.          end;
  66.   This has the unfortunate side-effect of wasting 100 bytes, but it works.
  67.  
  68. }
  69.  
  70. menTop : string[52] =                      { the top bar menu      }
  71. 'Database|Files|Update|Calculate|Report|Globals|Tools';
  72.  
  73. men1 : string[36]=                         { goes under 'Database' }
  74. ' Retrieve | Save | Put Away | Erase ';
  75.  
  76. men2 : string[76]=                         { goes under 'Files'    }
  77. ' Choose File | Browse Fields | Index | Filters | Add File | Modify Structure ';
  78.  
  79. men3 : string[31]=                         { goes under 'Update'   }
  80. ' Browse | Find | Search | List ';
  81.  
  82. men4 : string[1] =                         { goes under 'Calculate'}
  83. ' ';
  84.  
  85. men5 : string[55]=                         { goes under 'Report'   }
  86. ' Create Report | Modify Report Format | Print a Report ';
  87.  
  88. men6 : string[18]=                         { goes under 'Globals'  }
  89. ' Printer | Status ';
  90.  
  91. men7 : string[35] =                        { goes under 'Tools'    }
  92. ' Directory | Op. System | Chg. Dir ';
  93.  
  94.  
  95.  
  96. procedure msg(s:string);                   { an all-purpose job for each
  97.                                              menu choice
  98.                                            }
  99.  begin
  100.     makewindow(2,20,10,20,7,textattr,'Pulldown Result');
  101.     writeln;
  102.     writeln('Main Choice: ',choice);
  103.     writeln('Sub-Choice:  ',choice2);
  104.     writeln(s);
  105.     writeln;
  106.     write('Press Enter'); readln;
  107.     closewindow(2);
  108.  end;
  109.  
  110.  
  111. begin
  112.   checkbreak:=FALSE;
  113.  
  114.   { choice and choice2 are globals defined in pulldown.tpu }
  115.  
  116.   repeat
  117.     pulldownmenu(menTop,choice,choice2,choice,choice2);
  118.     case choice of
  119.       0 : msg('Quit');
  120.       1 : case choice2 of
  121.             1 : msg('Retreive a DB');
  122.             2 : msg('Save a DB');
  123.             3 : msg('Put away DB');
  124.             4 : msg('Erase a DB');
  125.           end;
  126.       2 : case choice2 of
  127.             1 : msg('Choose a file');
  128.             2 : msg('Set Browse fields');
  129.             3 : msg('Choose index');
  130.             4 : msg('Set filter');
  131.           end;
  132.       3 : case choice2 of
  133.             1 : msg('Browse records');
  134.             2 : msg('Find a record');
  135.             3 : msg('Search for a string');
  136.             4 : msg('List index');
  137.           end;
  138.       4 : msg('Calculate...');
  139.       5 : msg('Report menu...');
  140.       6 : case choice2 of
  141.             1 : msg('Set printer codes');
  142.             2 : msg('Get status data');
  143.           end;
  144.       7 : case choice2 of
  145.             1 : msg('Display directory');
  146.             2 : msg('Operating system');
  147.             3 : msg('Change working directory');
  148.           end;
  149.     end;
  150.   until choice = 0;
  151. end.